#pragma once

extern "C" {
/// C interface to autdesk fbx api
/// Colors are 0-1 RGBA
typedef long int32;
typedef unsigned long uint32;
typedef char charType;

/// Returns a file handle on success, 0 on failure.
int32 CGraphFBXCreateParseContext();
void CGraphFBXFreeParseContext( int32 context );
int32 CGraphFBXGetLastErrorStrLen( int32 context );
void CGraphFBXGetLastErrorStr( int32 context, charType* errorBuffer );

/// Smashes pivots into unified space.  Returns 0 on error, 1 otherwise.
void CGraphFBXLoadFile( int32 context, const charType* file );

//General properties
uint32 CGraphFBXGetNodeCount( int32 context );
uint32 CGraphFBXGetMaterialCount( int32 context );
uint32 CGraphFBXGetTextureCount( int32 context );
uint32 CGraphFBXGetSceneGraphEdgeCount( int32 context );

//These objects all have variable properties.
//0 is not a valid property list index
uint32 CGraphFBXGetNodePropertyList( int32 context, uint32 index );
uint32 CGraphFBXGetMaterialPropertyList( int32 context, uint32 index );
uint32 CGraphFBXGetTexturePropertyList( int32 context, uint32 index );
uint32 CGraphFBXGetCameraPropertyList( int32 context, uint32 index );
uint32 CGraphFBXGetLightPropertyList( int32 context, uint32 index );
uint32 CGraphFBXGetPropertyListCount( int32 context, uint32 propertyList );

///Enumerations are float property types that are always
/// Returns EFbxType
uint32 CGraphFBXGetPropertyType( int32 context, uint32 propertyList, uint32 propIndex );
uint32 CGraphFBXGetPropertyNameLength( int32 context, uint32 propertyList, uint32 propIndex );
void CGraphFBXGetPropertyName( int32 context, uint32 propertyList, uint32 propIndex, charType* buffer );

uint32 CGraphFBXGetNamePropertyLength( int32 context, int32 propertyList, uint32 propIndex );
void CGraphFBXGetNameProperty( int32 context, int32 propertyList, uint32 propIndex, charType* buffer );

void CGraphFBXGetDoubleProperty( int32 context, int32 propertyList, uint32 propIndex, double* buffer );


//ENodeAttachmentType
int32 CGraphFBXGetNodeAttachmentType( int32 context, uint32 node );
//Index longo the geometry,camera,or light vectors.
uint32 CGraphFBXGetNodeAttachment( int32 context, uint32 node );


//An edge is a pair of nodes, and thus each edge is *TWO*
//longegers.  The length of the edge list must be 2*numEdges.es.
void CGraphFBXGetSceneGraphEdges( int32 context, uint32 index, uint32* edgeList);

/// So there should be triangleCount*3 indexes in the index buffers.
uint32 CGraphFBXGetGeometryTriangleCount( int32 context, uint32 geometry );

uint32 CGraphFBXGetGeometryIndexBufferCount( int32 context, uint32 geometry );

enum EGeometryIndexBufferType
{
	EGeometryIndexBufferTypeNone,
	EGeometryIndexBufferTypePolygonVertex,
	EGeometryIndexBufferTypePolygonCount,
	EGeometryIndexBufferTypeNormal,
	EGeometryIndexBufferTypeDiffuse,
	EGeometryIndexBufferTypeAmbient,
	EGeometryIndexBufferTypeEmissive,
	EGeometryIndexBufferTypeSpecular,
	EGeometryIndexBufferTypeNormalMap,
	EGeometryIndexBufferTypeBumpMap,
	EGeometryIndexBufferTypeSmoothingGroup,
	EGeometryIndexBufferTypePolygonGroup, //No idea what this does.
};

uint32 CGraphFBXGetGeometryIndexBufferType( int32 context, uint32 geometry, uint32 bufferIndex );
//Returns the geometry buffer this index buffer refers to, if any.
//For smoothing group semantics there is not referencing buffer.
uint32 CGraphFBXGetGeometryIndexBufferGeometryBuffer( int32 context, uint32 geometry, uint32 bufferIndex );

uint32 CGraphFBXGetGeometryIndexBufferMappingMode( int32 context, uint32 geometry, uint32 bufferIndex );

/// Depending on the mapping mode, there may not be any indexes (size will be zero).
uint32 CGraphFBXGetGeometryIndexBufferSize( int32 context, uint32 geometry, uint32 bufferIndex );
void CGraphFBXGetGeometryIndexBuffer( int32 context, uint32 geometry, uint32 bufferIndex, uint32* buffer );

double CGraphFBXGetGeometryIndexBufferTextureAlpha( int32 context, uint32 geometry, uint32 bufferIndex );
uint32 CGraphFBXGetGeometryIndexBufferTextureBlendMode( int32 context, uint32 geometry, uint32 bufferIndex );
uint32 CGraphFBXGetGeometryIndexBufferTextureCount( int32 context, uint32 geometry, uint32 bufferIndex );
uint32 CGraphFBXGetGeometryIndexBufferTexture( int32 context, uint32 geometry, uint32 bufferIndex, uint32 textureIndex );


/// Geometry buffer 0 is always the position buffer.
uint32 CGraphFBXGetGeometryBufferSize( int32 context, uint32 geometry, uint32 index );
uint32 CGraphFBXGetGeometryBufferStride( int32 context, uint32 geometry, uint32 index );
void CGraphFBXGetGeometryBuffer( int32 context, uint32 geometry, uint32 index, double* outData );
//Index into the scene material list.
uint32 CGraphFBXGetGeometryMaterial( int32 context, uint32 geometry );

}